import java.util.Scanner;
/*这个题思路有点难*/

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int num = sc.nextInt();
            System.out.println(countDigitOne(num));
        }
    }
     // 迭代法
    public static int countDigitOne(int n) {
        int res = 0;
        int rate = 1; // 即为现在的位，个位1，10位10
        int all1nums = 0;
        int afterHalf = 0;
        while (n != 0) {


            int temp = n % 10;

            if (temp > 1) {
                res = temp * all1nums + res + rate; // 每增加1位在原来的基础上会出现：多的这一位所有的all，以及改为1工业多少个
            } else if (temp == 1){
                res = temp * all1nums + res + afterHalf + 1 ;
            }
            afterHalf = afterHalf + temp * rate;
            all1nums = all1nums * 10 + rate;
            rate *= 10;
            n /= 10;
        }
        return res;
    }
}
